public class Main {
    public static void main(String[] args) {
        String s = "   abc   def   ";
        String s1 = s.trim();
        System.out.println(s1);//"abc   def"
    }
    public static void main17(String[] args) {
        String s = "abcdefghijk";
        String s1 = s.substring(7);
        System.out.println(s1);//hijk
        String s2 = s.substring(7, 9);
        System.out.println(s2);//hi
    }
    public static void main16(String[] args) {
        String s = "abc def ghi";
        String[] strings1 = s.split(" ");
        for (int i = 0; i < strings1.length; i++) {
            System.out.println(strings1[i]);//abc,def,ghi
        }
        String[] strings2 = s.split(" ", 2);
        for (int i = 0; i < strings2.length; i++) {
            System.out.println(strings2[i]);//abc,def ghi
        }
    }
    public static void main15(String[] args) {
        String s = "abcdefabcdef";
        String s1 = s.replaceAll("ab", "ba");
        System.out.println(s1);//bacdefbacdef
        String s2 = s.replaceFirst("ab", "ba");
        System.out.println(s2);//bacdefabcdef
    }
    public static void main14(String[] args) {
        String date = String.format("%d %d %d", 1999, 12, 31);
        System.out.println(date);
    }
    public static void main13(String[] args) {
        char[] chars = {'h', 'e', 'l', 'l', 'o'};
        String s = new String(chars);
        System.out.println(s);//hello
    }
    public static void main12(String[] args) {
        String s = "hello";
        char[] chars = s.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            System.out.print(chars[i] + " ");//h e l l o
        }
    }
    public static void main11(String[] args) {
        String s1 = "HELLO";
        String s2 = "HEllo";
        System.out.println(s1.toLowerCase());//hello
        System.out.println(s2.toLowerCase());//hello
    }
    public static void main10(String[] args) {
        String s1 = "hello";
        String s2 = "hellO";
        System.out.println(s1.toUpperCase());//HELLO
        System.out.println(s2.toUpperCase());//HELLO
    }
    public static void main9(String[] args) {
        int res1 = Integer.parseInt("1234");//1234
        System.out.println(res1);
        double res2 = Double.parseDouble("12.99");//12.99
        System.out.println(res2);
    }
    public static void main8(String[] args) {
        System.out.println(String.valueOf(102));//102
        System.out.println(String.valueOf(10.99));//10.99
        System.out.println(String.valueOf(true));//true
    }
    public static void main7(String[] args) {
        String s = "abcdefabcdef";
        System.out.println(s.lastIndexOf('c'));//8
        System.out.println(s.lastIndexOf('c', 7));//2
        System.out.println(s.lastIndexOf("de"));//9
        System.out.println(s.lastIndexOf("de", 8));//3
    }
    public static void main6(String[] args) {
        String s = "abcdefabcdef";
        System.out.println(s.indexOf('c'));//2
        System.out.println(s.indexOf('c', 3));//8
        System.out.println(s.indexOf("de"));//3
        System.out.println(s.indexOf("de", 4));//9
    }
    public static void main5(String[] args) {
        String s  = "abcdefg";
        System.out.println(s.charAt(2));//c
    }
    public static void main4(String[] args) {
        String s1 = "hello";
        String s2 = "heLLO";
        String s3 = "HELLO";

        System.out.println(s1.compareToIgnoreCase(s2));//true
        System.out.println(s1.compareToIgnoreCase(s3));//true
    }
    public static void main3(String[] args) {
        String s1 = "hello";
        String s2 = "world";
        String s3 = "hello";
        String s4 = "abc";

        System.out.println(s1.compareTo(s2));//>0
        System.out.println(s1.compareTo(s3));//=0
        System.out.println(s1.compareTo(s4));//<0
    }
    public static void main2(String[] args) {
        String s1 = "hello";
        String s2 = "hello";
        String s3 = "Hello";

        System.out.println(s1.equals(s2));//true
        System.out.println(s1.equals(s3));//false
    }
    public static void main1(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("hello");
        String s3 = new String("world");
        String s4 = s1;
        System.out.println(s1 == s2);   // false
        System.out.println(s2 == s3);   // false
        System.out.println(s1 == s4);   // true
    }
}